package routers

import (
	"quickstart/controllers"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
)

func UserRouterInit() {
	beego.Router("/", &controllers.MainController{})

	beego.Router("/user/", &controllers.UserController{}, "get:Page")
	beego.Router("/user/:id:int", &controllers.UserController{}, "get:Show")
	beego.Router("/user/edit/:id:int", &controllers.UserController{}, "get:Edit")
	beego.Router("/user/update/:id:int", &controllers.UserController{}, "post:Update")
	beego.Router("/user/delete/:id:int", &controllers.UserController{}, "get:Delete")
	beego.AutoRouter(&controllers.UserController{})

	ns := beego.NewNamespace("/v1", beego.NSGet("/notallowed", func(ctx *context.Context) {
		ctx.Output.Body([]byte("notAllowed"))
	}))

	beego.AddNamespace(ns)
}
